//
//  WkWebView.h
//  XianjinXia
//
//  Created by Xianjinkd on 2017/7/3.
//  Copyright © 2017年 lxw. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>

@class CommonWebView;
@protocol WkWebViewDelegate <NSObject>
@optional
- (void)wkwebView:(CommonWebView *)webview didFinishLoadingURL:(NSString *)strURL;
- (void)wkwebView:(CommonWebView *)webview didFailToLoadURL:(NSString *)strURL error:(NSError *)error;
- (bool)wkwebView:(CommonWebView *)webview shouldStartLoadWithURL:(NSString *)strURL;
- (void)wkwebViewDidStartLoad:(CommonWebView *)webview;
- (void)handJS:(WKScriptMessage *)message;
@end

@interface CommonWebView : UIView<WKUIDelegate, WKScriptMessageHandler, WKNavigationDelegate>

#pragma mark - Public Properties

//zlcdelegate
@property (nonatomic, weak) id <WkWebViewDelegate> delegate;

// The main and only UIProgressView
@property (nonatomic, strong) UIProgressView *progressView;
// The web views
// Depending on the version of iOS, one of these will be set
@property (nonatomic, strong) WKWebView *wkWebView;
@property (nonatomic, strong) UIWebView *uiWebView;



#pragma mark - Initializers view
- (instancetype)initWithFrame:(CGRect)frame;


#pragma mark - Static Initializers
@property (nonatomic, strong) UIBarButtonItem *actionButton;// 操作按钮
@property (nonatomic, strong) UIColor *tintColor;
@property (nonatomic, strong) UIColor *barTintColor;
@property (nonatomic, assign) BOOL actionButtonHidden;// 操作按钮隐藏
@property (nonatomic, assign) BOOL showsURLInNavigationBar;// 在导航栏显示URL地址
@property (nonatomic, assign) BOOL showsPageTitleInNavigationBar;// 在导航栏显示页面标题

//Allow for custom activities in the browser by populating this optional array
@property (nonatomic, strong) NSArray *customActivityItems;

#pragma mark - Public Interface

// Load a NSURLURLRequest to web view
// Can be called any time after initialization
- (void)loadRequest:(NSURLRequest *)request;

// Load a NSURL to web view
// Can be called any time after initialization
- (void)loadURL:(NSURL *)URL;

// Loads a URL as NSString to web view
// Can be called any time after initialization
- (void)loadURLString:(NSString *)URLString;


// Loads an string containing HTML to web view
// Can be called any time after initialization
- (void)loadHTMLString:(NSString *)HTMLString;

@end
